package com.wc.AlgoOJ._贪心.助学金;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/11/2 1:17
 * @description http://43.138.190.70:8888/p/AG0113
 */
public class Main {
    /**
     * 思路：
     * 按照分数从高到底排序
     * 枚举每一个可能的中位数, 然后在前面找 需要援助的 最少的 N / 2 个, 从后面 找需要援助的最小的 N / 2 个, 找不到说明没有
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static int[][] a = new int[N][2];
    // 存后面 n - N / 2 + 1开始的排序
    static int[] b = new int[N];
    static int[] num = new int[N];
    static PriorityQueue<Integer> maxq = new PriorityQueue<>(Comparator.reverseOrder());
    static int n, m, bn = 0;
    static long F;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        F = sc.nextLong();
        for (int i = 1; i <= m; i++) {
            a[i][0] = sc.nextInt();
            a[i][1] = sc.nextInt();
        }
        Arrays.sort(a, 1, m + 1, Comparator.comparingInt(o -> -o[0]));
        long preSum = 0;
        for (int i = 1; i <= n / 2; i++) {
            preSum += a[i][1];
            maxq.add(a[i][1]);
        }
        for (int i = n / 2 + 2; i <= m; i++) {
            b[++bn] = a[i][1];
            num[a[i][1]]++;
        }
        Arrays.sort(b, 1, bn + 1);
        long lastSum = 0;
        // 前 n / 2个
        for (int i = 1; i <= n / 2; i++) lastSum += b[i];
        // 次大值坐标
        int j = n / 2 + 1;
        int res = -1;
        // 可能的值
        for (int i = n / 2 + 1; i <= m - n / 2; i++) {
            if (preSum + a[i][1] + lastSum <= F) {
                res = a[i][0];
                break;
            }
            // 从前面插入一个, 出来一个, 用堆实现
            maxq.add(a[i][1]);
            preSum = preSum + a[i][1] - maxq.poll();
            // 从后面插入一个, 出来一个, 用双指针实现
            if (a[i][1] <= b[j - 1]) {
                lastSum -= a[i][1];
                // 找到第一个次大值完成
                while (num[b[j]] == 0) j++;
                lastSum += b[j];
                j++;
            }
            // 表示当前出来了
            num[a[i][1]]--;
        }

        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
